import { Injectable } from '@nestjs/common';
import { InjectModel } from '@nestjs/mongoose';

@Injectable()
export class GoodsAttrService {
    constructor(@InjectModel('GoodsAttr') private readonly goodsAttrModel) {}
    async find(where = {}, fields = null) {
        return await this.goodsAttrModel.find(where, fields).sort({ sort: 1 });
    }
    async create(goodsAttrInfo) {
        return await this.goodsAttrModel.create(goodsAttrInfo);
    }
    async update(goodsAttrInfo) {
        return await this.goodsAttrModel.updateOne({ _id: goodsAttrInfo._id }, goodsAttrInfo);
    }
    async delete(goodsAttrInfo) {
        return await this.goodsAttrModel.deleteOne(goodsAttrInfo);
    }
    getModel() {
        return this.goodsAttrModel;
    }
}
